﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;

namespace BLL.BLL
{
    public class BLLAccount
    {

        public static void LoadLenNhanVien(ComboBox cb, List<NhanVien> ds)
        {
            cb.Items.Clear();
            foreach (var item in ds)
                cb.Items.Add(item);
            cb.ValueMember = "MaNhanVien";
            cb.DisplayMember = "TenNhanVien";
            cb.Items.Insert(0, "--- Nhan Vien ---");
            cb.SelectedIndex = 0;



        }
        public static void LoadLenNhanVien(ComboBox cb, IQueryable<NhanVien> ds)
        {
            cb.Items.Clear();
            foreach (var item in ds)
                cb.Items.Add(item);
            cb.ValueMember = "MaNhanVien";
            cb.DisplayMember = "TenNhanVien";
            cb.Items.Insert(0, "--- Nhan Vien ---");
            cb.SelectedIndex = 0;



        }

        public static void LoadGiaiDau(ComboBox cbgiaidau, IQueryable<GiaiDau> ds)
        {
            cbgiaidau.Items.Clear();
            foreach (var item in ds)

                cbgiaidau.Items.Add(item);

            cbgiaidau.ValueMember = "MaGiaiDau";
            cbgiaidau.DisplayMember = "TenGiaiDau";
            cbgiaidau.Items.Insert(0, "--- Tên Giải ---");
            cbgiaidau.SelectedIndex = 0;


        }
        public static bool KiemTra(string s, IQueryable<GiaiDau> ds)
        {
            foreach (var item in ds)
                if (item.TenGiaiDau == s)
                    return true;
            return false;


        }
        public static bool KiemTra(string s, IQueryable<TaiKhoan> ds)
        {

            foreach (var item in ds)
                if (item.UserName == s)
                    return true;
            return false;



        }
        public static void LoadListView(ListView listview, IQueryable<TaiKhoan> ds)
        {
            
            listview.Items.Clear();
            foreach (var item in ds)
            {

                ListViewItem it = new ListViewItem(item.UserName);
                it.SubItems.Add(item.Password);
                listview.Items.Add(it);
            }



        }
        public static void LoadListView(ListView listview, List<TaiKhoan> ds)
        {

            listview.Items.Clear();
            foreach (var item in ds)
            {

                ListViewItem it = new ListViewItem(item.UserName);
                it.SubItems.Add(item.Password);
                listview.Items.Add(it);
            }



        }
        public static void LoadTCB(ToolStripComboBox cbpq,IQueryable<BoPhan>ds)
        {
            foreach (var item in ds)
                cbpq.Items.Add(item);
            cbpq.ComboBox.ValueMember = "MaBoPhan";
            cbpq.ComboBox.DisplayMember = "TenBoPhan";
            cbpq.Items.Insert(0, "--- Bộ Phận ---");
            cbpq.ComboBox.SelectedIndex = 0;


        }
       
    }
}
